<?php
class Bemigo_Recommend_Hunch{
	protected $_hunchApi;

	public function __construct(Bemigo_Service_Hunch $hunchApi){
		$this->_hunchApi = $hunchApi;
	}

	public function __call($fn, $params){
		$response = array();
		$results = $this->_hunchApi->$fn($params[0]);
		if($results->ok == true && !empty($results->results)){
			foreach($results->results as $result){
				if(!empty($result->image_url)){
					$aliases = null;
					if(!empty($result->aliases)){
						$aliases = implode(",", $result->aliases);
					}
					array_push($response, array("name"=>$result->name, "image_url"=>$result->image_url, "result_id"=>$result->result_id, "aliases"=>$aliases));
				}
			}
		}
		return $response;
	}
}